#!/bin/sh
SDK_VERION=V7.3.2
SDK_NAME=output_yoc_v7.3.2
SDK_ROOT=../../$SDK_NAME
YOC_ROOT=..
SLN_NAME=smart_lighting_w800
SLN_DIR=solutions
BOARD_DIR=boards
BOARD_NAME="board_w800"

rm -fr $SDK_ROOT
mkdir -p $SDK_ROOT
mkdir -p $SDK_ROOT/components
mkdir -p $SDK_ROOT/$BOARD_DIR
mkdir -p $SDK_ROOT/$SLN_DIR

echo ">>>>Main comp"
cd ${SLN_NAME}
comps=`yoc show -c |  grep "\* " |awk -F' ' '{printf "%s\n", $2}'`
cd -

for comp in $comps
do
    echo $comp
    cp -rf $YOC_ROOT/components/$comp $SDK_ROOT/components
done


# boards
echo ">>>>Boards sln"
for board in $BOARD_NAME
do
    echo $BOARD_DIR/$board
    cp -rf $YOC_ROOT/$BOARD_DIR/$board $SDK_ROOT/$BOARD_DIR
done

#clean
cp -rf ${SLN_NAME} $SDK_ROOT/$SLN_DIR
cp $YOC_ROOT/.yoc $SDK_ROOT/.

#debug
#exit

#create .yoc
echo "yoc_version: v7.3.2" > $SDK_ROOT/.yoc
echo "username: test" >> $SDK_ROOT/.yoc
echo "password: test" >> $SDK_ROOT/.yoc
echo "occ_host: test" >> $SDK_ROOT/.yoc

#tar
cd $YOC_ROOT/../
zip -qr ${SDK_NAME}.zip ${SDK_NAME}
cd -

#clean
#rm $SDK_ROOT -rf
